#!/usr/bin/env python
# coding: utf-8
"""
@Author : ZhaoBin
@Date   : 2018-12-15 14:58:31
@Last Modified by   : ZhaoBin
@Last Modified time : 2018-12-16 18:38:14
"""
import base64
import json
import os
import random
import re
import time
import traceback
import urllib
import uuid
from binascii import a2b_hex, b2a_hex

import requests
from Crypto import Random
from Crypto.Cipher import AES
# import SendKeys
from pykeyboard import PyKeyboard
# 导入webdriver
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
# 要想调用键盘按键操作需要引入keys包
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select

import config
# import database as db
import huilian_file_tools
import huilian_selenium
import inter
import pub
import settings
from pipelines import mysql


# 主要用来测试selenium使用phantomJs
class implement_class():
    """
    澳大利亚签证系统
    """
    kb = PyKeyboard()
    logger = settings.get_log("implement")
    _tb_info  = "dc_business_australia_info_eng"
    _tb_order = "dc_business_australia_order"

    # 待上传文件本地存放根目录,各个国家可以在此基础上加上国家编码的下级文件夹  例如：E:\\visafile\\260\\
    local_path = 'E:\\visafile'

    #开启会话
    requests = requests.Session()
    requests.verify = False
    requests.headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0',
        'Accept': '*/*',
        'Accept-Encoding': 'gzip, deflate',
        'Accept-Language': 'zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3'
    }
    requests.timeout = 60    # 超时时间:1分钟

    def __init__(self, id, extra, steps):
        self.app_id = id
        self.extra = extra
        self.steps = steps
        self.local_path = self.local_path + '112/' + str(self.app_id) + '/'
        # 调用环境变量指定的PhantomJS浏览器创建浏览器对象
        # self.driver = webdriver.PhantomJS()
        # self.driver.set_window_size(1366, 768)
        # self.driver.set_window_size(1440, 900)
        self.Tools = huilian_selenium.Tools()
        self.FileTools = huilian_file_tools.FileTools()
        self.Datetools = huilian_selenium.Datetools()
        self.initParmar()
        chrome_options = huilian_selenium.chromeOptions()
        chrome_path = r'C:\Program Files (x86)\Google\Chrome\Application\chromedriver'
        self.driver = webdriver.Chrome(executable_path=chrome_path, chrome_options=chrome_options)
        self.huilianTools = huilian_selenium.Huilian(self.driver)
        self.driver.maximize_window()

    # 签证信息 参数
    def initParmar(self):
        sql, val = self.asql.select_sql(
            tb=self._tb_info,
            cond={"status": 1}
        )
        self.app = self.asql.getOne(sql, val)
        self.app.update({
            "application_id": "EGOKMCZQGQ",
            "order_id": 1,
            "application_status": 1,
            "all_reasons_access": "[3]",
            "any_important_date": "2019/01/12",
            "government_is": "1",
            "english_name": "chen",
            "english_name_s": "xiaoyun",
            "username": "陈小云",
            "china_name": "陈",
            "china_name_s": "小云",
            "group_type": "1",
            "sex": "M",
            "date_birth": "1978-12-21",
            "passport_number": "EA6678974",
            "lssue_date": "2017-07-17",
            "expiration_date": "2027-07-16",
            "place_issue_province": "BEIJING",
            "identity_number": "330325197812217638",
            "id_lssue_date": "2011-11-14",
            "id_expiration_date": "2031-11-14",
            "date_province": "ZHEJIANG",
            "date_city": "ZHEJAING",
            "date_country": "PRCH",
            "marriage": "M",
        })
        self.moreinfo = None
        self.userName = 'flyvisa@163.com'  # 登陆账号
        self.password = 'QWEqwe123'  # 登陆密码
        self.stream = '29'  # 申请人的流   29旅游  31商务  30赞助家庭游   61频繁的旅行（商业目的）

        # 境外 -> 访问澳大利亚的所有理由  2:商业，3:旅游，4:探亲，5:研究，6:宗教活动，7:其他
        self.visitReason = self.app['all_reasons_access'][1:-1].split(",")
        # 澳大利亚期间重要时间节点
        # 境外 -> 请详细说明申请人需要在澳大利亚的任何重要日期
        self.significantDates = self.app['any_important_date']
        # 组 id: order_id
        self.order_id = self.app["order_id"]

        # 姓名 中-英
        self.fullName   = self.app["username"]          # 全名 - 中
        self.firstCName = self.app["china_name"]        # 姓 - 中
        self.lastCName  = self.app["china_name_s"]      # 名 - 中
        self.firstEName  = self.app["english_name"]     # 姓 - 英
        self.lastEName = self.app["english_name_s"]     # 名 - 英

        # 创建组时, 选择类型: 1: 家庭 2: 学校/学习 3: 奖励旅游 4: 工作/雇主 5: 友 6: 其他 7: 娱乐 8: 运动队/体育赛事
        self.group_type = self.app["group_type"]
        # 性别 1：男  2：女 3：其他
        self.sex = self.app["sex"]
        self.birthday = self.Tools.convertDateForAustralia(str(self.app["date_birth"]))  # 出生日期
        self.passport = self.app['passport_number']  # 护照号码
        self.passportStarTime = self.Tools.convertDateForAustralia(str(self.app['lssue_date']))  # 护照开始日期
        self.passportEndTime = self.Tools.convertDateForAustralia(str(self.app['expiration_date']))  # 护照开始日期
        self.passportProvince = self.Tools.convertProvinceForAustralia(self.app['place_issue_province'])  # 护照发行省
        self.idCard = self.app["identity_number"]  # 身份证号
        self.idCardStarTime = self.Tools.convertDateForAustralia(str(self.app["id_lssue_date"]))  # 身份证开始时间
        self.idCardEndTime = self.Tools.convertDateForAustralia(str(self.app["id_expiration_date"]))  # 身份证结束时间

        # 3 place_of_birth
        self.city       = self.app['date_city']  # 出生所在市
        self.province   = self.Tools.convertProvinceForAustralia(self.app["date_province"])  # 出生所在省
        self.country    = self.app["date_country"]

        # 3 relationship_status
        # F:同居 D:离婚 E:订婚 M:已婚 N:未婚 S:分局 W:丧偶
        self.relationshipStatus = self.app['marriage']

    # 数据库操作
    @property
    def asql(self):
        return mysql()

    def log(self, info="", debug="", error=""):
        """
        输出日志
        """
        # return
        if info:
            self.logger.info(f"{self.fullName} {info}")
        elif debug:
            self.logger.debug(f"{self.fullName} {debug}")
        elif error:
            self.logger.error(f"{self.fullName} {error}")

    # 从页面获取
    def find_page(self, strs=None, name=1):
        page = self.huilianTools.page
        text1 = page.split(strs[0])[-1]
        text2 = text1[text1.find(strs[1]):].split(strs[2])[0]
        s = "name" if name else "id"
        return pub.get_reg_value(fr'(?<={s}=").*?(?=")', text2)

    def testAoLogin(self):
        try:
            # get方法会一直等到页面加载，然后才会继续程序，通常测试会在这里选择# time.sleep(2)
            self.driver.get("https://online.immi.gov.au/lusc/login")
            # 输入登陆用户名
            self.log(f"输入登陆用户名: {self.userName}")
            self.huilianTools.send_keys((By.NAME, 'username'), self.userName)
            # 输入登陆密码
            self.log(f"输入登陆密码: {self.password}")
            self.huilianTools.send_keys((By.NAME, 'password'), self.password)
            self.huilianTools.click((By.NAME, 'login'))
            self.huilianTools.click((By.NAME, 'continue'), 2)
            # 打印数据内容
            # self.huilianTools.click((By.NAME,'btn_newapp'),2)
            # time.sleep(2)
            # 新增订单
            if self.Tools.is_empty(self.app['application_id']):
                self.log(f"新增订单")
                self.huilianTools.click((By.NAME, 'btn_newapp'), 2)
                # time.sleep(1)
                # self.huilianTools.click((By.ID, 'mainpanel_parentSection_1b0a0bd_o'), 2)
                # self.huilianTools.js_execute('document.getElementById("mainpanel_parentSection_1b0a0bd-content").setAttribute("aria-expanded", true)')
                self.log(f"点击 new_application")
                self.huilianTools.click((By.ID, "mainpanel_parentSection_1b0a0bd1c0-body"))
                # time.sleep(1)
                # self.huilianTools.click((By.ID, 'mainpanel_parentSection_1b0a0bd1c'), 2)
                # # time.sleep(1)
                self.page1()
            else:
                self.log(f"已有订单: {self.app['application_id']}")
                # text=self.driver.page_source
                # index = text.find('Reference No')
                # text=text[index:index+100]
                # index = text.find('<div class="wc-input">')
                # index2 = text.find('</div>')
                # text=text[index+22:index2]
                # self.app['application_id']=text
                self.huilianTools.send_keys((By.NAME, 'i_instantSearchFld'), self.app['application_id'])
                self.huilianTools.click((By.NAME, 'btn_perform_instant_srch'), 2)
                # time.sleep(2)
                if self.app['application_status'] == 1:
                    self.huilianTools.click((By.ID, 'defaultActionPanel_0_1'), 2)
                    # time.sleep(1)
                    self.page1()
                elif self.app['application_status'] == 2:
                    self.huilianTools.click((By.ID, 'defaultActionPanel_0_0'), 2)
                    # time.sleep(1)
                    self.pageDoc()
                elif self.app['application_status'] == 3:
                    self.huilianTools.click((By.ID, 'actionPanel_0_9'), 2)
                    # time.sleep(1)
                    self.pagePay()
                else:
                    self.driver.quit()
                pass
            pass
            # self.huilianTools.click((By.ID,'mainpanel_parentSection_1b0a0bc_o'),2)
            # self.huilianTools.click((By.ID,'mainpanel_parentSection_1b0a0bc1c'),2)
        except BaseException as e:
            self.except_log(e)
    pass

    # 第一页填写内容
    def page1(self):
        self.log(f"进入第一页")
        try:
            # time.sleep(2)
            text = self.driver.page_source
            index = text.find('I have read and agree to the terms and conditions')
            text = text[0:index]
            index = text.rfind('<label')
            text = text[0:index]
            index = text.rfind('<input')
            text = text[index:len(text)]
            # 阅读条款
            id = pub.get_reg_value(r'(?<=input id=").*?(?=")', text)
            # self.huilianTools.click((By.ID,id),2)
            js = f"document.getElementById('{id}').checked = true"
            self.driver.execute_script(js)
            # 下一步按钮为动态 需要截取字符串获取
            self.huilianTools.click((By.XPATH, "//span[text()='Next']"))
            # time.sleep(1)
            self.page2()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第二页填写内容
    def page2(self):
        try:
            # # time.sleep(15)
            # 如果没有订单号   就查询并保存订单号
            if self.Tools.is_empty(self.app['application_id']):
                self.huilianTools.click((By.XPATH, '//button[@title="Link to account page" and @type="submit"]'), 2)
                text = self.driver.page_source
                index = text.find('Reference No')
                text = text[index: index + 100]
                index = text.find('<div class="wc-input">')
                index2 = text.find('</div>')
                text = text[index + 22: index2]
                self.app['application_id'] = text
                logger = settings.get_log("application_id")
                logger.info(f"application_id: {self.app['application_id']}")
                # db.save("app", {"application_id": text}, "id=%s", [self.app_id])
                # db.save("app", {"application_status": '1'}, "id=%s", [self.app_id])
                self.huilianTools.click((By.ID, 'defaultActionPanel_0_1'), 2)
                # time.sleep(1)
                self.page1()
            pass
            text = self.driver.page_source
            text = text.split('Is the applicant currently outside Australia?')[-1]
            text = text.split('Yes', 1)[0]
            testid = text.split('id="')[-1].split('"')[0]
            # 申请人是否在澳大利亚外  选择是
            self.huilianTools.click((By.ID, testid))
            # # time.sleep(5)
            # 当前国家
            self.huilianTools.select_by_value((By.CSS_SELECTOR, '.ELP-F4257>select[id$="input"]'), 'PRCH')
            # 申请人所在申请地的法律地位  默认选1 公民
            self.huilianTools.select_by_value((By.CSS_SELECTOR, '.ELP-F4258>select[id$="input"]'), '1')
            # # time.sleep(5)
            # 选择申请类型  默认选第一个 旅游类型
            self.huilianTools.click((By.XPATH, '//input[@value="' + self.stream + '"]'), 2)
            # self.huilianTools.click((By.XPATH,'//*/input[@name="'+testName+'" and @value="'+self.stream+'"]'))
            # [i.click() for i in self.huilianTools.find_elements((By.CSS_SELECTOR, 'button[title="Remove item. Shift + click remove button to remove all."]'), 1)]
            # 访问澳大利亚的所有理由 选择旅游
            for i, v in enumerate(self.visitReason):
                self.huilianTools.click((By.CSS_SELECTOR, 'button[title="Add item"]')) if i else ""
                self.huilianTools.select_by_value((By.CSS_SELECTOR, 'ul>li:first-child>select'), v)
            # 详细说明申请人在澳大利亚重要日期
            self.huilianTools.find_element((By.CSS_SELECTOR, ".ELP-F3767>textarea")).send_keys(self.significantDates)
            # 这个应用程序是作为一组应用程序的一部分提交的吗？默认选否
            text = self.huilianTools.page
            page = text.split("Is this application being lodged as part of a group of applications?")[-1]
            page = page[page.find("<label"):].split("</label>", 2)
            group_name = pub.get_reg_value(r'(?<=name=").*?(?=")', page[0])

            # 查询是否为组
            sql = self.asql.select_sql(
                tb=self._tb_info,
                cond="order_id=%s"
            )
            if self.asql.getNum(sql, self.order_id) > 1:
                self.huilianTools.click((By.XPATH, f'//*/input[@name="{group_name}" and @value="1"]'), 2)
                page2 = page[2].split("Select group")[0]
                group_btn = page2[int(page2.find("<button")):]
                group_btn_id = pub.get_reg_value(r'(?<=id=").*?(?=")', group_btn)
                self.huilianTools.click((By.ID, group_btn_id))
                order_sql = self.asql.select_sql(
                    tb=self._tb_order,
                    sel="group_num",
                    cond="id=%s"
                )
                group_num = self.asql.getOne(sql, self.order_id).get("group_num")
                self.huilianTools.find_element((By.XPATH, "//*[text()='Has the group already been created?']"))
                # 组名是否已经存在
                text = self.huilianTools.page
                page_group = text.split("Has the group already been created?<")[-1]
                page_split = page_group[page_group.find("<label"):].split("</label>", 2)
                page_input = page_split[0]
                page_other = page_split[2]
                group_input_name = pub.get_reg_value(r'(?<=name=").*?(?=")', page_input)
                if group_num and len(group_num) > 5:
                    # 有组名, 查询
                    group_id_page = page_split[2]
                    self.huilianTools.click((By.XPATH, f'//*/input[@name="{group_input_name}" and @value="1"]'), 2)
                    # 组 Group ID 输入
                    group_id_span = group_id_page[group_id_page.find("Group ID"):]
                    group_id_span2 = group_id_span[group_id_span.find("<input"):].split("</span>")[0]
                    group_id_input = pub.get_reg_value(r'(?<=name=").*?(?=")', group_id_span2)
                    self.huilianTools.send_keys((By.XPATH, f'//*/input[@name="{group_id_input}" and @value="1"]'), group_num)
                else:
                    # 无组名, 创建
                    self.huilianTools.click((By.XPATH, f'//*/input[@name="{group_input_name}" and @value="2"]'), 2)
                    # 输入组名 英文姓+签证类型
                    g_n1 = page_other.split("Group name")[-1]
                    g_n2 = g_n1[g_n1.find("<input"):].split("</span>")[0]
                    g_n_id = pub.get_reg_value(r'(?<=id=").*?(?=")', g_n2)
                    self.huilianTools.send_keys((By.ID, g_n_id), self.firstEName + self.stream)
                    # 选择组类型
                    g_t1 = page_other.split("Group type")[-1]
                    g_t2 = g_t1[g_t1.find("<select"):].split("</span>")[0]
                    g_t_id = pub.get_reg_value(r'(?<=id=").*?(?=")', g_t2)
                    self.huilianTools.select_by_value((By.ID, g_t_id), self.group_type)
                confirm_btn = page_other[:page_other.find("Confirm")].split("<button")[-1]
                confirm = pub.get_reg_value(r'(?<=id=").*?(?=")', confirm_btn)
                self.huilianTools.click((By.ID, confirm))
            else:
                self.huilianTools.click((By.XPATH, f'//*/input[@name="{group_name}" and @value="2"]'), 2)

            # time.sleep(1)
            if self.stream == "29":
                # 申请人是外国政府的代表，还是搭乘联合国通行证，还是豁免团体的成员？ 选择否
                st1 = "Is the applicant a representative of a foreign government, or travelling on a United Nations Laissez-Passer, or a member of an exempt group?"
                gove_id = self.find_page([st1, "<input", "</span>"])
                self.huilianTools.click((By.XPATH, f'//*/input[@name="{gove_id}" and @value="2"]'), 2)
            # 下一步
            self.huilianTools.click((By.XPATH, "//span[text()='Next']"))
            # time.sleep(1)
            self.page3()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第三页填写内容
    def page3(self):
        try:
            text = self.driver.page_source
            requires = re.findall(r'<script type=[\'"]text/javascript[\'"] class=[\'"]registrationScripts[\'"]>(.*?)</script>', text)[0].replace(" ", "")
            con = json.loads(re.findall(r"c\.register\((.*?)\);", requires)[0])[0]
            index = text.find('Applicant')
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]

            all_page = {
                "place_of_birth": 9,
                "relationship_status": 11,
                "other_names_spellings": 12,
                "citizenship": 13,
                "other_passports": 14,
                "other_identity_documents": 15,
                "health_examination": 18
            }

            names = con.replace(titleId, "")
            two = names[:2]
            oth = names[2:]

            # 姓
            self.huilianTools.send_keys((By.CSS_SELECTOR, f"[name^={titleId + pub.fmst(two, -37, 0) + pub.fmst(oth, 1, 0)}]"), self.firstEName)
            # 名
            self.huilianTools.send_keys((By.CSS_SELECTOR, f"[name^={titleId + pub.fmst(two, -37, 0) + pub.fmst(oth, 2, 0)}]"), self.lastEName)
            # 性别(男)
            self.huilianTools.click((By.XPATH, f'//input[@type="radio" and @value="{self.sex}"]'), 2)
            # 出生日期
            self.huilianTools.send_keys((By.NAME, titleId + pub.fmst(two, -35, 0) + oth), self.birthday)
            # 护照号码
            self.huilianTools.send_keys((By.NAME, titleId + pub.fmst(two, -1, 0) + oth), self.passport)
            # 护照国家
            self.huilianTools.select_by_value((By.NAME, titleId + two + oth), 'CHN')
            # 护照持有人国籍
            self.huilianTools.select_by_value((By.NAME, titleId + pub.fmst(two, 1, 0) + oth), 'CHN')
            # 护照发行日期
            self.huilianTools.send_keys((By.NAME, titleId + pub.fmst(two, 2, 0) + oth), self.passportStarTime)
            # 护照到期日期
            self.huilianTools.send_keys((By.NAME, titleId + pub.fmst(two, 3, 0) + oth), self.passportEndTime)
            # 护照发行省
            self.huilianTools.select_visibility_by_text((By.CSS_SELECTOR, f"[name^={titleId + pub.fmst(two, 4, 0) + oth}]"), self.passportProvince)
            # 是否有中国身份证
            self.huilianTools.click((By.CSS_SELECTOR, f'[name^={titleId + pub.fmst(names, 0, 0)}][value="1"] '), 2)
            # 如果存在身份信息  先删除
            self.deleteData()
            # 添加身份证信息
            reg = r"\{id:'(%s[a-z0-9]{2})'"
            reg = reg % titleId
            ids = re.findall(reg, requires)
            self.huilianTools.click((By.CSS_SELECTOR, f"button[name^={ids[4]}]"), 2)
            # time.sleep(1)
            self.addIdCard()
            text = self.driver.page_source
            index = text.find('Applicant')
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]

            # ======================== #
            # ==== place_of_birth ==== #
            attr = ".wc-content .wc-content>div"
            labels = self.get_labels(titleId, all_page["place_of_birth"], attr)
            # 城镇
            labels[1].find_element_by_tag_name("input").send_keys(self.city)
            # 省份
            labels[2].find_element_by_tag_name("input").send_keys(self.province)
            # 国籍
            self.huilianTools.select_has_element(labels[3].find_element_by_tag_name("select"), value='PRCH')

            # ============================= #
            # ==== relationship_status ==== #
            attr = "select"
            labels = self.get_labels(titleId, all_page["relationship_status"], attr)
            # 婚姻状态
            self.huilianTools.select_has_element(labels[0], value=self.relationshipStatus)

            # =============================== #
            # ==== other_names_spellings ==== #
            attr = "input"
            labels = self.get_labels(titleId, all_page["other_names_spellings"], attr)
            # 是否有其他名字
            testName = titleId + 'bc1b1a0'
            self.log(self.nameUsedBefore)
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="{self.nameUsedBefore}"]'), 2)
            # 如果有   则添加曾用名
            if self.nameUsedBefore == '1':
                # time.sleep(1)
                self.huilianTools.click((By.NAME, titleId + 'bc3b'), 2)
                # time.sleep(1)
                text = self.driver.page_source
                index = text.find('Other names / spellings')
                text = text[0:index]
                index = text.rfind('<h2 id=')
                text = text[index:len(text)]
                tmpTitleId = pub.get_reg_value(r'(?<=h2 id=").*?(?=")', text)
                tmpTitleId = tmpTitleId[0: len(tmpTitleId) - 2]
                # 曾用姓
                self.huilianTools.send_keys((By.NAME, tmpTitleId + 'c0a1a0'), self.beforeFirstName)
                # 曾用名
                self.huilianTools.send_keys((By.NAME, tmpTitleId + 'c1a1a0'), self.beforeLastName)
                # 修改原因
                self.huilianTools.select_by_value((By.NAME, tmpTitleId + 'd0b0a'), self.updateReason)
                # 如果修改原因选择其他  则填写详细信息
                if self.updateReason == 'O':
                    # time.sleep(1)
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'e0b0'), self.updateDetails)
                pass
                self.huilianTools.click((By.XPATH, '//button[@title="保存当前条目" and @type="submit"]'), 2)
                # time.sleep(1)
            pass
            # 是否是中国公民
            testName = titleId + 'bd1b1a0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 申请人是否是其他国家的公民？
            testName = titleId + 'bd2b1a0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人有其他护照吗？默认填没有
            testName = titleId + 'be1b1a0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人是否有其他身份证明文件？
            testName = titleId + 'bf1b1a0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人是否在过去12个月为澳大利亚签证进行体检？
            testName = titleId + 'bi1b1a0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 体检详情
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            # self.huilianTools.click((By.NAME,nextId),2)  # 下一步到第四页
            self.huilianTools.click((By.NAME, nextId), 2)
            # time.sleep(1)
            self.page4()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第四页填写内容
    def page4(self):
        try:
            # 确认信息是否正确
            self.huilianTools.click((By.XPATH, '//input[@type="radio" and @value="1"]'), 2)
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第五页
            # time.sleep(1)
            text = self.driver.page_source
            index = text.find('Warning!')
            if index > -1:
                # time.sleep(10)
                text = self.driver.page_source
                index = text.rfind('Confirm')
                text = text[0:index]
                index = text.rfind('<button')
                text = text[index:len(text)]
                titleId = pub.get_reg_value(
                    r'(?<=button name=").*?(?=")', text)
                self.huilianTools.click((By.NAME, titleId), 2)  # 下一步到第五页
                # time.sleep(1)
                self.page6()
            else:
                self.page5()
            pass
        except BaseException as e:
            self.except_log(e)
    pass

    # 第五页填写内容
    def page5(self):
        try:
            text = self.driver.page_source
            index = text.find('Additional identity questions')
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]
            # 申请人是否曾前往澳大利亚或先前申请签证？
            testName = titleId + 'c1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="{self.oldVisa}"]'), 2)
            if self.oldVisa == '1':
                # 申请人是否有以前曾前往澳大利亚的护照
                testName = titleId + 'c2f1b0'
                self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="{self.oldGoAustraliaPassport}"]'), 2)
                if self.oldGoAustraliaPassport == '1':
                    # time.sleep(1)
                    self.huilianTools.click((By.NAME, titleId + 'c2g1'), 2)
                    # time.sleep(10)
                    text = self.driver.page_source
                    index = text.find('Previous passports')
                    text = text[0:index]
                    index = text.rfind('<div id=')
                    text = text[index:len(text)]
                    tmpTitleId = pub.get_reg_value(
                        r'(?<=div id=").*?(?=")', text)
                    tmpTitleId = tmpTitleId[0: len(tmpTitleId) - 1]
                    # 其他护照姓
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'e0a0b0a'), self.opFamilyName)
                    # 其他护照名
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'e0b0b0a'), self.opGivenName)
                    # 其他护照性别
                    self.huilianTools.click(
                        (By.XPATH, f'//input[@name="{tmpTitleId}e1a1a" and @value="{self.opSex}"]'), 2)
                    # 其他护照出生日期
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'e2a1a'), self.opBirthday)
                    # 其他护照护照号
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'f0b0'), self.opPassport)
                    # 其他护照护照国家
                    self.huilianTools.select_by_value(
                        (By.NAME, tmpTitleId + 'g0b0'), 'CHN')
                    # 其他护照护照持有人国籍
                    self.huilianTools.select_by_value(
                        (By.NAME, tmpTitleId + 'h0b0'), 'CHN')
                    # 护照发行日期
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'i0b0'), self.opPassportStarTime)
                    # 护照到期日期
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'j0b0'), self.opPassportEndTime)
                    # 护照发行省
                    self.huilianTools.select_visibility_by_text(
                        (By.NAME, tmpTitleId + 'ba0b0a'), self.opPassportProvince)
                    self.huilianTools.click(
                        (By.XPATH, '//button[@title="Save the current entry" and @type="submit"]'), 2)
                    # time.sleep(1)
                pass
                # 申请人有澳大利亚签证申请号吗？
                testName = titleId + 'c3b1b0a'
                self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            pass
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第六页
            # time.sleep(1)
            self.page6()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第六页填写内容
    def page6(self):
        try:
            text = self.driver.page_source
            index = text.find('Travelling companions')
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]
            self.deleteData()
            self.huilianTools.click((By.XPATH, '//input[@type="radio" and @value="2"]'), 2)
            for i in range(len(self.family_list)):
                family = self.family_list[i]
                if str(family['is_travelling_with_you']) == '1' and str(family['is_contacts']) != '1':
                    self.huilianTools.click(
                        (By.XPATH, '//input[@type="radio" and @value="1"]'), 2)
                    # time.sleep(1)
                    self.huilianTools.click((By.NAME, titleId + 'd1'), 2)
                    # time.sleep(1)
                    text = self.driver.page_source
                    index = text.rfind('Travelling companion')
                    text = text[0:index]
                    index = text.rfind('<div id=')
                    text = text[index:len(text)]

                    tmpTitleId = pub.get_reg_value(
                        r'(?<=div id=").*?(?=")', text)
                    tmpTitleId = tmpTitleId[0: len(tmpTitleId) - 1]
                    # 同行人姓
                    self.huilianTools.send_keys(
                        (By.ID, tmpTitleId + 'd0a0b0a_input'), family['lang_surnames'])
                    # 同行人关系
                    self.huilianTools.select_by_value(
                        (By.ID, tmpTitleId + 'c0b0a_input'), self.Tools.convertFamilyRelationForAustralia(family['relation']))
                    # 同行人名
                    self.huilianTools.send_keys(
                        (By.ID, tmpTitleId + 'd0b0b0a_input'), family['lang_given_names'])
                    # 同行人性别
                    if str(family['sex']) == '10201':
                        self.huilianTools.click(
                            (By.XPATH, f'//input[@name="{tmpTitleId}d1a1a" and @value="M"]'), 2)
                    else:
                        self.huilianTools.click(
                            (By.XPATH, f'//input[@name="{tmpTitleId}d1a1a" and @value="F"]'), 2)
                    # 同行人出生日期
                    self.huilianTools.send_keys(
                        (By.ID, tmpTitleId + 'd2a1a_input'), self.Tools.convertDateForAustralia(str(family['birthday'])))
                    self.huilianTools.click(
                        (By.XPATH, '//button[@title="Save the current entry" and @type="submit"]'), 2)
                    # time.sleep(1)
                pass
            pass
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第七页
            self.page7()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第七页填写内容
    def page7(self):
        try:
            text = self.driver.page_source
            index = text.find('Contact details')
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]
            # 通常居住国
            self.huilianTools.select_by_value((By.NAME, titleId + 'b1a1a0'), 'PRCH')
            # text=self.driver.page_source
            # index = text.rfind('Australia, ACT Regional Office')
            # text=text[0:index]
            # index =text.rfind('id="')
            # text=text[index:len(text)]
            # id=pub.get_reg_value(r'(?<=id=").*?(?=")', text)
            # id=id[0 : len(titleId) - 1]
            # # time.sleep(2)
            # 申请人可能被要求参加澳大利亚政府机关的面试。哪一个办公室离申请人最近的位置最近？默认填北京
            self.huilianTools.send_keys((By.ID, titleId + 'c3a1a0_input'), 'China, Guangzhou')
            # 居住地址  国家
            self.huilianTools.select_by_value((By.NAME, titleId + 'd3a1a'), 'PRCH')
            # time.sleep(1)
            # 街道
            self.huilianTools.send_keys((By.NAME, titleId + 'd4a1a0'), self.address)
            # 城镇
            self.huilianTools.send_keys((By.NAME, titleId + 'd7a0b0'), self.city)
            # time.sleep(1)
            # 居住地址  省份
            self.huilianTools.select_visibility_by_text((By.NAME, titleId + 'd7b1a1a'), self.province)
            # 邮编
            self.huilianTools.send_keys((By.NAME, titleId + 'd7c0b0'), self.postalCode)
            # 家庭电话
            self.huilianTools.send_keys((By.NAME, titleId + 'e2a1a'), self.homePhone)
            # 业务电话
            self.huilianTools.send_keys((By.NAME, titleId + 'e3a1a'), self.businessPhone)
            # 手机
            self.huilianTools.send_keys((By.NAME, titleId + 'e4a1a'), self.mobile)
            # 邮寄地址与住址相同吗  默认选是
            self.huilianTools.click((By.XPATH, '//input[@type="radio" and @value="1"]'), 2)
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第八页
            # time.sleep(1)
            self.page8()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第八页填写内容
    def page8(self):
        try:
            text = self.driver.page_source
            index = text.find('Authorised recipient')
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]
            testName = titleId + 'b1b0'
            # 授权部门将所有书面信件直接发送给申请人 默认选否
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="NO"]'), 2)
            # time.sleep(1)
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第九页
            # time.sleep(1)
            self.page9()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第九页填写内容
    def page9(self):
        try:
            text = self.driver.page_source
            index = text.find('Non-accompanying members of the family unit')
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]
            # 申请人是否有任何非澳大利亚公民或澳大利亚永久居民前往澳大利亚的家庭成员？
            self.deleteData()
            self.huilianTools.click((By.XPATH, '//input[@type="radio" and @value="2"]'), 2)
            # if self.family =='1':
            # pass
            for i in range(len(self.family_list)):
                family = self.family_list[i]
                if str(family['is_travelling_with_you']) != '1' and str(family['is_contacts']) != '1':
                    self.huilianTools.click(
                        (By.XPATH, '//input[@type="radio" and @value="1"]'), 2)
                    # time.sleep(1)
                    self.huilianTools.click((By.NAME, titleId + 'c1'), 2)
                    # time.sleep(1)
                    text = self.driver.page_source
                    index = text.rfind(
                        'Non-accompanying member of the family unit')
                    text = text[0:index]
                    index = text.rfind('<div id=')
                    text = text[index:len(text)]
                    tmpTitleId = pub.get_reg_value(
                        r'(?<=div id=").*?(?=")', text)
                    tmpTitleId = tmpTitleId[0: len(tmpTitleId) - 1]
                    # 非同行人关系
                    self.huilianTools.select_by_value(
                        (By.NAME, tmpTitleId + 'c0b0a'), self.Tools.convertFamilyRelationForAustralia(family['relation']))
                    # 非同行人姓
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'e0a0b0a'), family['lang_surnames'])
                    # 非同行人名
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'e0b0b0a'), family['lang_given_names'])
                    # 非同行人性别
                    if str(family['lang_sex']) == '10201':
                        self.huilianTools.click(
                            (By.XPATH, f'//input[@name="{tmpTitleId}e1a1a" and @value="M"]'), 2)
                    else:
                        self.huilianTools.click(
                            (By.XPATH, f'//input[@name="{tmpTitleId}e1a1a" and @value="F"]'), 2)
                    # 同行人出生日期
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'e2a1a'), self.Tools.convertDateForAustralia(str(family['birthday'])))
                    self.huilianTools.select_by_value(
                        (By.NAME, tmpTitleId + 'f0b0a'), 'PRCH')
                    self.huilianTools.click(
                        (By.XPATH, '//button[@title="Save the current entry" and @type="submit"]'), 2)
                    # time.sleep(1)
                pass
            pass
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第十页
            # time.sleep(1)
            self.page10()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第十页填写内容
    def page10(self):
        try:
            text = self.driver.page_source
            index = text.find('Entry to Australia')
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]
            testName = titleId + 'c1b1a'
            # 申请人是否打算多次进入澳大利亚？
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="{self.entryCount}"]'), 2)
            if self.entryCount == '1':
                # time.sleep(1)
                testName = titleId + 'c8a1b0'
                # 申请人是否知道每次前往澳大利亚的时间？
                self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="{self.knowGoAustraliaDat}"]'), 2)
                if self.knowGoAustraliaDate == '1':
                    # 添加时间
                    self.huilianTools.click((By.NAME, titleId + 'c8c1'), 2)
                    # time.sleep(1)
                    text = self.driver.page_source
                    index = text.find('Give details of the additional entry.')
                    text = text[0:index]
                    index = text.rfind('<div id=')
                    text = text[index:len(text)]
                    tmpTitleId = pub.get_reg_value(
                        r'(?<=div id=").*?(?=")', text)
                    tmpTitleId = tmpTitleId[0: len(tmpTitleId) - 1]
                    # 计划到达日期
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'c0a1a'), self.plannedArrivalDate)
                    # 计划离开日期
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'c1a1a'), self.plannedFinalDepartureDate)
                    # 去澳大利亚的原因
                    self.huilianTools.send_keys(
                        (By.NAME, tmpTitleId + 'd0b0'), self.gotoDetail)
                    tmpTitleId = tmpTitleId[0: len(tmpTitleId) - 9]
                    self.huilianTools.click((By.NAME, tmpTitleId + 'd3'), 2)
                    # time.sleep(1)
                else:
                    # 不知道前往澳大利亚时间的原因
                    self.huilianTools.send_keys(
                        (By.NAME, titleId + 'c8b0b0'), self.notKnowDateDetail)
                pass
            pass

            # 逗留时间 默认选择3个月
            self.huilianTools.select_by_value((By.NAME, titleId + 'c4a1a'), str(self.stayAusTime))
            # time.sleep(3)
            # 计划到达日期
            self.huilianTools.send_keys((By.NAME, titleId + 'c5a1a'), self.plannedArrivalDate)
            # 计划离开日期
            self.huilianTools.send_keys((By.NAME, titleId + 'c6a1a'), self.plannedFinalDepartureDate)
            # 申请人将在澳大利亚进行一门课程吗 默认选否
            testName = titleId + 'e1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人是否会在澳大利亚访问任何亲戚、朋友或联系人？ 默认选否
            testName = titleId + 'f1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            if str(str(self.app['has_contact_in_the_country'])) == '1':
                self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
                # time.sleep(1)
                for i in range(len(self.extra_list)):
                    if str(self.extra_list[i]['extra_type']) == '9':
                        family = self.extra_list[i]
                        self.huilianTools.click((By.NAME, titleId + 'f2b'), 2)
                        # time.sleep(1)
                        text = self.driver.page_source
                        index = text.rfind('Contact in Australia')
                        text = text[0:index]
                        index = text.rfind('<div id=')
                        text = text[index:len(text)]
                        tmpTitleId = pub.get_reg_value(
                            r'(?<=div id=").*?(?=")', text)
                        tmpTitleId = tmpTitleId[0: len(tmpTitleId) - 1]
                        # 联系人关系
                        self.huilianTools.select_by_value(
                            (By.NAME, tmpTitleId + 'c2a1a0'), self.Tools.convertExtraRelationForAustralia(family['relation']))
                        # 联系人姓
                        self.huilianTools.send_keys(
                            (By.NAME, tmpTitleId + 'e0a0b0a'), family['lang_surnames'])
                        # 联系人名
                        self.huilianTools.send_keys(
                            (By.NAME, tmpTitleId + 'e0b0b0a'), family['lang_given_names'])
                        # 联系人性别
                        if str(family['lang_sex']) == '10201':
                            self.huilianTools.click(
                                (By.XPATH, f'//input[@name="{tmpTitleId}e1a1a" and @value="M"]'), 2)
                        else:
                            self.huilianTools.click(
                                (By.XPATH, f'//input[@name="{tmpTitleId}e1a1a" and @value="F"]'), 2)
                        # 联系人出生日期
                        self.huilianTools.send_keys(
                            (By.NAME, tmpTitleId + 'e2a1a'), self.Tools.convertDateForAustralia(str(family['birthday'])))
                        # 联系人居住国家
                        self.huilianTools.select_by_value(
                            (By.NAME, tmpTitleId + 'f3a1a'), 'A')
                        self.huilianTools.send_keys(
                            (By.NAME, tmpTitleId + 'f4a1a0'), family['lang_addr'])
                        self.huilianTools.send_keys(
                            (By.NAME, tmpTitleId + 'f6a0b0'), family['lang_city'])
                        self.huilianTools.select_visibility_by_text(
                            (By.NAME, tmpTitleId + 'f6b0b0'), family['lang_province'])
                        self.huilianTools.send_keys(
                            (By.NAME, tmpTitleId + 'f6c0b0'), family['post_code'])
                        self.huilianTools.send_keys(
                            (By.NAME, tmpTitleId + 'g2a1a'), family['tel'].replace('-', ''))
                        self.huilianTools.send_keys(
                            (By.NAME, tmpTitleId + 'g3a1a'), family['work_tel'].replace('-', ''))
                        self.huilianTools.send_keys(
                            (By.NAME, tmpTitleId + 'g4a1a'), family['mobile'].replace('-', ''))
                        self.huilianTools.send_keys(
                            (By.NAME, tmpTitleId + 'h2a1a0'), family['email'])
                        self.huilianTools.select_by_value(
                            (By.NAME, tmpTitleId + 'j0b0a'), str(family['contact_type']))
                        self.huilianTools.click(
                            (By.XPATH, '//button[@title="Save the current entry" and @type="submit"]'), 2)
                        # time.sleep(1)
                    pass
                pass
            pass
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第十一页（页面显示12）
            # time.sleep(1)
            self.page12()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第十一页（页面显示12）填写内容
    def page12(self):
        try:
            text = self.driver.page_source
            index = text.find("Visa applicant's current overseas employment")
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]
            # 就业状况
            self.huilianTools.select_by_value((By.NAME, titleId + 'b1a1a'), self.workType)
            # time.sleep(1)
            if self.workType == '1'or self.workType == '2':
                # 职业分组
                self.huilianTools.select_by_value((By.NAME, titleId + 'b3a1a'), str(self.workGroup))
                if str(self.workGroup) == '070299':
                    # 工作职业
                    self.huilianTools.send_keys(
                        (By.NAME, titleId + 'b4a1a'), self.workTitle)
                pass
                # 工作单位
                self.huilianTools.send_keys((By.NAME, titleId + 'b5a1a0'), self.workOrganization)
                # 工作开始时间
                self.huilianTools.send_keys((By.NAME, titleId + 'b6a1a'), self.workStartDate)
                # 国家
                self.huilianTools.select_by_value((By.NAME, titleId + 'h3a1a'), 'PRCH')
                # 详细地址
                self.huilianTools.send_keys((By.NAME, titleId + 'h4a1a0'), self.workAddress)
                # 城镇
                self.huilianTools.send_keys((By.NAME, titleId + 'h7a0b0'), self.workCity)
                # time.sleep(5)
                # 省份
                self.huilianTools.select_visibility_by_text((By.NAME, titleId + 'h7b1a1a'), self.workProvince)
                # 邮编
                self.huilianTools.send_keys((By.NAME, titleId + 'h7c0b0'), self.workPostCode)
                # 商务电话
                self.huilianTools.send_keys((By.NAME, titleId + 'j2a1a'), self.workBusPhone)
                # 手机
                self.huilianTools.send_keys((By.NAME, titleId + 'j3a1a'), self.mobile)
                # 邮件
                self.huilianTools.send_keys((By.NAME, titleId + 'ba2a1a0'), self.workEmail)
            pass
            if self.workType == '3':
                # 失业时间
                self.huilianTools.send_keys((By.NAME, titleId + 'e4a1a'), self.unemploymentTime)
                # 上一个工作
                self.huilianTools.send_keys((By.NAME, titleId + 'e5a1a'), self.oldWrok)
            pass
            if self.workType == '4':
                # 退休时间
                self.huilianTools.send_keys((By.NAME, titleId + 'd2a1a'), self.retirementTime)
            pass
            if self.workType == '5':
                # 专业
                self.huilianTools.send_keys((By.NAME, titleId + 'c3a1a'), self.professional)
                # 学校
                self.huilianTools.send_keys((By.NAME, titleId + 'c4a1a'), self.school)
                # 入学时间
                self.huilianTools.send_keys((By.NAME, titleId + 'c5a0b0'), self.schoolStartTime)
                # 毕业时间
                self.huilianTools.send_keys((By.NAME, titleId + 'c5b0b0'), self.schoolEndTime)
            pass
            if self.workType == '99':
                # 详细信息
                self.huilianTools.send_keys((By.NAME, titleId + 'b2a1a'), self.workDeatil)
            pass
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第十三页
            # time.sleep(1)
            self.page13()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第十三页填写内容
    def page13(self):
        try:
            text = self.driver.page_source
            index = text.find("Financial support")
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]
            testName = titleId + 'b3b1a'
            # 详述申请人在澳大利亚逗留期间的资金情况。
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="{self.financialType}"]'), 2)
            if str(self.financialType) != '1':
                # 支持类型
                self.huilianTools.select_by_value((By.NAME, titleId + 'b4a1a'), self.supportType)
            pass
            if str(self.financialType) == '3' or str(self.financialType) == '4':
                # 国家
                self.huilianTools.select_by_value((By.NAME, titleId + 'h0a1a'), 'PRCH')
                # time.sleep(1)
                # 详细地址
                self.huilianTools.send_keys((By.NAME, titleId + 'h1a1a0'), self.supportAddress)
                # 省
                self.huilianTools.select_visibility_by_text((By.NAME, titleId + 'h4b1a1a'), self.supportProvince)
                # 城镇
                self.huilianTools.send_keys((By.NAME, titleId + 'h4a0b0'), self.supportCity)
                # 邮编
                self.huilianTools.send_keys((By.NAME, titleId + 'h4c0b0'), self.supportPostCode)
            pass
            if str(self.financialType) == '4':
                self.huilianTools.select_by_value((By.NAME, titleId + 'c2a1a0'), self.supportRelationship)
                # 姓
                self.huilianTools.send_keys((By.NAME, titleId + 'f0a1a0'), self.supportFamilyName)
                # 名
                self.huilianTools.send_keys((By.NAME, titleId + 'f1a1a0'), self.supportGivenName)
            pass
            # 申请人将有哪些资金支持他们在澳大利亚的逗留
            self.huilianTools.send_keys((By.NAME, titleId + 'b5a1a0'), self.financialDetail)
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第十四页（页面显示16）
            # time.sleep(1)
            self.page16()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第十四页（页面显示16）填写内容
    def page16(self):
        try:
            text = self.driver.page_source
            index = text.find("Health declarations")
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]
            # 在过去五年中，是否有申请人连续三个月访问或居住在护照国境外？ 默认否
            testName = titleId + 'b1b0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 在澳大利亚，是否有申请人打算进入医院或医疗机构（包括疗养院）？ 否
            testName = titleId + 'd1b0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 在澳大利亚逗留期间，申请人是否打算从事牙科医生、护士或护理人员的工作或学习？ 否
            testName = titleId + 'f1b0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 有肺结核相关疾病吗？ 否
            testName = titleId + 'bc0b0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            testName = titleId + 'bf0b0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人是否因医疗条件需要调动或照料？ 否
            testName = titleId + 'bh1b0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第十七页
            # time.sleep(1)
            self.page17()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第十七页填写内容
    def page17(self):
        try:
            text = self.driver.page_source
            index = text.find("Character declarations")
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]
            # 申请人被指控犯有目前正在等待法律诉讼的罪行？ 否
            testName = titleId + 'e1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 是否有任何申请人在任何国家被判有罪（包括从官方记录中删除的任何定罪）？ 否
            testName = titleId + 'f1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 是否有任何申请人曾获逮捕令或国际刑警组织通知？ 否
            testName = titleId + 'g1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人是否曾被判犯有涉及儿童的性犯罪（包括没有定罪记录的地方）？ 否
            testName = titleId + 'h1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 是否有任何申请人在性犯罪登记册上被提名？ 否
            testName = titleId + 'i1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人是否因无心或精神错乱而被判无罪？ 否
            testName = titleId + 'j1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 是否有任何申请人被一个不适合辩护的法院发现？ 否
            testName = titleId + 'ba1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 是否有任何申请人曾直接或间接参与或参与在澳大利亚或任何其他国家可能对国家安全构成风险的活动？ 否
            testName = titleId + 'bb1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人是否曾因种族灭绝、战争罪、危害人类罪、酷刑、奴役或其他严重国际罪行而被起诉或起诉？ 否
            testName = titleId + 'bc1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人是否曾与海外或澳大利亚从事暴力或暴力行为（包括战争、叛乱、自由斗争、恐怖主义、抗议）的组织有联系？ 否
            testName = titleId + 'be1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人曾经在军事部队、警察部队、国家赞助的/私人的民兵或情报机构（包括秘密警察）工作过吗？ 否
            testName = titleId + 'bf1b0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人是否接受过任何军事/准军事训练、武器/爆炸物训练或化学/生物制品制造训练？ 否
            testName = titleId + 'bh1b0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人是否曾参与过走私或贩卖人口罪？ 否
            testName = titleId + 'bj1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 是否有任何申请人被驱逐出境、驱逐出境或被排除在任何国家（包括澳大利亚）？ 否
            testName = titleId + 'ca1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 是否有申请人在任何国家（包括澳大利亚）签证过期？ 否
            testName = titleId + 'cb1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 是否有任何申请人曾向澳大利亚政府或澳大利亚的任何公共当局提供过未偿还的债务？ 否
            testName = titleId + 'cc1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 任何申请人是否曾与曾参与或参与犯罪行为的人、团体或组织有联系？ 否
            testName = titleId + 'bd1b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第十八页
            # time.sleep(1)
            self.page18()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第十八页填写内容
    def page18(self):
        try:
            text = self.driver.page_source
            index = text.find("Visa history")
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]
            # 申请人是否持有或正在申请澳大利亚或其他国家的签证？ 否
            testName = titleId + 'b1b0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="{self.otherVisa}"]'), 2)
            if str(self.otherVisa) == '1':
                self.huilianTools.send_keys((By.NAME, titleId + 'c0b0'), self.otherVisaDetail)
            pass
            # 申请人是否曾经在澳大利亚或任何其他国家，没有遵守签证条件，或离开其授权逗留期限？ 否
            testName = titleId + 'd1b0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            # 申请人是否曾申请过澳大利亚签证或其他国家拒绝或取消签证？ 否
            testName = titleId + 'f1b0'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第十九页(页面显示20)
            # time.sleep(1)
            self.page20()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第十九页(页面显示20)填写内容
    def page20(self):
        try:
            text = self.driver.page_source
            index = text.find("Declarations")
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 2]
            # 阅读并理解在本申请中提供给他们的信息？ 是
            testName = titleId + 'a4b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 在该表格的每一个细节上，以及在它的任何附件上都提供了完整和正确的信息？ 是
            testName = titleId + 'a5b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 如果本申请书提供了任何欺诈性文件或虚假或误导性的信息，申请将被拒绝 是
            testName = titleId + 'a6b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 请理解，如果发给签证后发现文件有欺诈性或信息不正确，签证随后可能被取消。 是
            testName = titleId + 'a7b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 当他们得知情况变化（包括地址变化）时，或在审议本申请时，如与本申请所提供或与本申请有关的信息有任何变化，将立即书面通知本署。 是
            testName = titleId + 'a9b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 已阅读隐私声明（表格1442I）中包含的信息。是
            testName = titleId + 'a11a1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 明白本署可收集、使用及披露申请人的个人资料（包括生物统计资料及其他敏感资料），如保密通知（表格1442i）所述。 是
            testName = titleId + 'a13a1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 请理解，如果这个签证没有附加8503条件，它将限制在澳大利亚停留超过批准的停留期限的能力。 是
            testName = titleId + 'b0b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 同意不接受学习或培训超过三个月。 是
            testName = titleId + 'c0b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 同意在签证停留期届满前或离开澳大利亚前离开。 是
            testName = titleId + 'd0b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 如有需要，同意收集指纹和面部图像。 是
            testName = titleId + 'e0b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 请理解，如果需要提供他们的指纹和面部图像，申请人的指纹、面部图像和由该部保存的传记信息可以被提供给澳大利亚执法机构，以帮助识别申请人并确定授予e签证申请，并为执法目的。 是
            testName = titleId + 'f0b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 同意澳大利亚执法机构向司法部披露申请人的生物特征、个人简历和犯罪记录信息，以帮助确定申请人，确定授予签证和执法目的的资格。 是
            testName = titleId + 'g0b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            # 同意移民局使用申请人为移民法或2007年《公民法》目的而取得的生物特征资料、传记资料和犯罪记录资料。 是
            testName = titleId + 'h0b1a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="1"]'), 2)
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到第二十一页
            # time.sleep(1)
            self.page21()
        except BaseException as e:
            self.except_log(e)
    pass

    # 第二十一页填写内容
    def page21(self):
        try:
            # time.sleep(10)
            text = self.driver.page_source
            index = text.find("Priority Consideration (fast-track) service")
            text = text[0:index]
            index = text.rfind('<div id=')
            text = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 1]
            # 申请人是否想申请优先考虑服务费？ 否
            testName = titleId + 'c1b0a'
            self.huilianTools.click((By.XPATH, f'//input[@name="{testName}" and @value="2"]'), 2)
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到确认页面
            # time.sleep(1)
            # 确认页面
            text = self.driver.page_source
            index = text.find('Next')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)  # 下一步到上传文档页面
            # time.sleep(1)
            self.pageDoc()
        except BaseException as e:
            self.except_log(e)
    pass

    def addIdCard(self):
        # 添加身份证页面
        text = self.driver.page_source
        requires = re.findall(r'<script type=[\'"]text/javascript[\'"] class=[\'"]registrationScripts[\'"]>(.*?)</script>', text)[0].replace(" ", "")
        ids = re.findall(r"c\.register\((.*?)\);", requires)
        index = text.find('National identity card')
        text = text[0:index]
        index = text.rfind('<div id=')
        text = text[index:len(text)]
        titleId = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
        titleId = titleId[0: len(titleId)]
        con = json.loads(ids[0])[0]
        cons = con.replace(titleId, "")
        fName = ids[1][1:-1]
        names = fName.replace(titleId, "")
        # a3a0b0a
        # 姓
        # self.huilianTools.send_keys((By.NAME, titleId + '0d0a1a0'), self.firstName)
        # self.huilianTools.send_keys((By.NAME, titleId + 'a3a0b0a'), self.firstName)
        self.huilianTools.send_keys((By.NAME, fName), self.firstEName)
        # 名
        # self.huilianTools.send_keys((By.NAME, titleId + '0d1a1a0'), self.lastName)
        # self.huilianTools.send_keys((By.NAME, titleId + 'a3b0b0a'), self.lastName)
        self.huilianTools.send_keys((By.NAME, titleId + pub.fmst(names[:3], "000001") + names[3:]), self.lastEName)
        # 身份证号
        # self.huilianTools.send_keys((By.NAME, titleId + '0e0b0'), self.idCard)
        # self.huilianTools.send_keys((By.NAME, titleId + 'a4a1a'), self.idCard)
        self.huilianTools.send_keys((By.NAME, titleId + pub.fmst(cons[:2], "0011") + cons[2:]), self.idCard)
        # 国籍
        # self.huilianTools.select_by_value((By.NAME, titleId + '0f0b0'), 'PRCH')
        # self.huilianTools.select_by_value((By.NAME, titleId + 'a5a1a'), 'PRCH')
        self.huilianTools.select_by_value((By.NAME, con), 'PRCH')
        # 身份证发行时间
        # self.huilianTools.send_keys((By.NAME, titleId + '0h0b0'), self.idCardStarTime)
        # self.huilianTools.send_keys((By.NAME, titleId + 'a7a1a'), self.idCardStarTime)
        self.huilianTools.send_keys((By.NAME, titleId + pub.fmst(cons[:2], "0002") + cons[2:]), self.idCardStarTime)
        # 到期时间
        # self.huilianTools.send_keys((By.NAME, titleId + '0i0b0'), self.idCardEndTime)
        # self.huilianTools.send_keys((By.NAME, titleId + '0i0b0'), self.idCardEndTime)
        self.huilianTools.send_keys((By.NAME, titleId + pub.fmst(cons[:2], "0003") + cons[2:]), self.idCardEndTime)
        # 下一步 回到第三页
        self.huilianTools.click((By.XPATH, '//button[text()="Confirm"]'), 2)
        # time.sleep(1)
    pass

    # 上传文件页面
    def pageDoc(self):
        try:
            # db.save("app", {"application_status": '2'}, "id=%s", [self.app_id])
            self.material_down()
            text    = self.driver.page_source
            index   = text.find('Photograph - Passport')
            text    = text[0:index]
            index   = text.rfind('<span id')
            text    = text[index:len(text)]
            titleId = pub.get_reg_value(r'(?<=span id=").*?(?=")', text)
            titleId = titleId[0: len(titleId) - 12]
            # 先删除文件
            # self.deleteDoc()
            familyDoc = '1'
            idCardDoc = '1'
            financialType = '1'
            invitationDoc = '1'
            passportDoc = '1'
            for i in range(len(self.fileList)):
                file = self.fileList[i]
                if str(file['material_id']) in ['712', '727', '741', '760']:
                    #Photograph - Passport照片
                    self.huilianTools.click((By.ID, titleId + '0'), 2)
                    # time.sleep(1)
                    titleId1 = titleId + '0b2c0b'
                    self.huilianTools.click((By.NAME, titleId1), 2)
                    # time.sleep(2)
                    # SendKeys.SendKeys(file['local_path'])
                    self.kb.type_string(file['local_path'])
                    # time.sleep(2)
                    # SendKeys.SendKeys("{ENTER}")
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    # SendKeys.SendKeys("{ENTER}")
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(10)
                    titleId2 = titleId + '0b2f0'
                    self.huilianTools.click((By.NAME, titleId2), 2)
                    # time.sleep(10)
                pass
                if str(file['material_id']) in ['713', '728', '742', '761']:
                    # Travel Document护照
                    if passportDoc == '1':
                        # Family register and composition form (if applicable)户口
                        self.huilianTools.click((By.ID, titleId + '1'), 2)
                        passportDoc = '2'
                        familyDoc = '1'
                        idCardDoc = '1'
                        financialType = '1'
                        invitationDoc = '1'
                    pass
                    # time.sleep(1)
                    titleId1 = titleId + '1b2a0b'
                    self.huilianTools.select_by_value(
                        (By.NAME, titleId1), 'DT132')
                    # time.sleep(5)
                    titleId1 = titleId + '1b2c0b'
                    self.driver.find_element_by_name(titleId1).click()
                    # self.huilianTools.click((By.NAME,titleId1),2)
                    # time.sleep(2)

                    self.kb.type_string(file['local_path'])
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(20)
                    titleId2 = titleId + '1b2f0'
                    self.driver.find_element_by_name(titleId2).click()
                    # time.sleep(10)
                pass
                if str(file['material_id']) in ['720', '734', '747', '767']:
                    # Travel Document护照其他页
                    if passportDoc == '1':
                        # Family register and composition form (if applicable)户口
                        self.huilianTools.click((By.ID, titleId + '1'), 2)
                        passportDoc = '2'
                        familyDoc = '1'
                        idCardDoc = '1'
                        financialType = '1'
                        invitationDoc = '1'
                    pass

                    # time.sleep(1)
                    titleId1 = titleId + '1b2a0b'
                    self.huilianTools.select_by_value(
                        (By.NAME, titleId1), 'DT471')
                    # time.sleep(5)
                    titleId1 = titleId + '1b2c0b'
                    self.driver.find_element_by_name(titleId1).click()
                    # self.huilianTools.click((By.NAME,titleId1),2)
                    # time.sleep(2)

                    self.kb.type_string(file['local_path'])
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(20)
                    titleId2 = titleId + '1b2f0'
                    self.driver.find_element_by_name(titleId2).click()
                    # time.sleep(10)
                pass
                if str(file['material_id']) in ['714', '729', '743', '762']:
                    # National Identity Document (other than Passport)  身份证

                    if idCardDoc == '1':
                        # Family register and composition form (if applicable)户口
                        self.huilianTools.click((By.ID, titleId + '2'), 2)
                        idCardDoc = '2'
                        familyDoc = '1'
                        financialType = '1'
                        invitationDoc = '1'
                        passportDoc = '1'
                    pass
                    # time.sleep(1)
                    titleId1 = titleId + '2b2c0b'
                    self.huilianTools.click((By.NAME, titleId1), 2)
                    # time.sleep(2)
                    self.kb.type_string(file['local_path'])
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(15)
                    titleId2 = titleId + '2b2f0'
                    self.huilianTools.click((By.NAME, titleId2), 2)
                    # time.sleep(10)
                pass
                if str(file['material_id']) == '99':
                    if familyDoc == '1':
                        # Family register and composition form (if applicable)户口
                        self.huilianTools.click((By.ID, titleId + '3'), 2)
                        # time.sleep(5)
                        familyDoc = '2'
                        idCardDoc = '1'
                        financialType = '1'
                        invitationDoc = '1'
                        passportDoc = '1'
                    pass
                    titleId1 = titleId + '3b2a0b'
                    # 上传54表单
                    self.huilianTools.select_by_value(
                        (By.NAME, titleId1), 'DT364')
                    # time.sleep(5)
                    titleId1 = titleId + '3b2c0b'
                    self.huilianTools.click((By.NAME, titleId1), 2)
                    # time.sleep(2)
                    self.kb.type_string(file['local_path'])
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(15)
                    titleId2 = titleId + '3b2f0'
                    self.huilianTools.click((By.NAME, titleId2), 2)
                    # time.sleep(10)
                pass
                if str(file['material_id']) in ['715', '730', '744', '763']:
                    if familyDoc == '1':
                        # Family register and composition form (if applicable)户口
                        self.huilianTools.click((By.ID, titleId + '3'), 2)
                        # time.sleep(5)
                        familyDoc = '2'
                        idCardDoc = '1'
                        financialType = '1'
                        invitationDoc = '1'
                        passportDoc = '1'
                    pass
                    titleId1 = titleId + '3b2a0b'
                    # 上传户口本
                    self.huilianTools.select_by_value(
                        (By.NAME, titleId1), 'DT053')
                    # time.sleep(5)
                    titleId1 = titleId + '3b2c0b'
                    self.huilianTools.click((By.NAME, titleId1), 2)
                    # time.sleep(2)
                    self.kb.type_string(file['local_path'])
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(15)
                    titleId2 = titleId + '3b2f0'
                    self.huilianTools.click((By.NAME, titleId2), 2)
                    # time.sleep(10)
                pass
                if str(file['material_id']) in ['716', '731', '764']:
                    if familyDoc == '1':
                        # Family register and composition form (if applicable)户口
                        self.huilianTools.click((By.ID, titleId + '3'), 2)
                        # time.sleep(5)
                        familyDoc = '2'
                        idCardDoc = '1'
                        financialType = '1'
                        invitationDoc = '1'
                        passportDoc = '1'
                    pass
                    titleId1 = titleId + '3b2a0b'
                    # 上传结婚证
                    self.huilianTools.select_by_value(
                        (By.NAME, titleId1), 'DT053')
                    # time.sleep(5)
                    titleId1 = titleId + '3b2c0b'
                    self.huilianTools.click((By.NAME, titleId1), 2)
                    # time.sleep(2)
                    self.kb.type_string(file['local_path'])
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(15)
                    titleId2 = titleId + '3b2f0'
                    self.huilianTools.click((By.NAME, titleId2), 2)
                    # time.sleep(10)
                pass
                if str(file['material_id']) in ['713', '728', '742', '761']:
                    # Evidence of planned tourism activities in Australia旅行证件
                    self.huilianTools.click((By.ID, titleId + '4'), 2)
                    # time.sleep(1)
                    titleId1 = titleId + '4b2a0b'
                    self.huilianTools.select_by_value(
                        (By.NAME, titleId1), 'DT366')
                    # time.sleep(5)
                    titleId1 = titleId + '4b2c0b'
                    self.huilianTools.click((By.NAME, titleId1), 2)
                    # time.sleep(2)
                    self.kb.type_string(file['local_path'])
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(15)
                    titleId2 = titleId + '4b2f0'
                    self.huilianTools.click((By.NAME, titleId2), 2)
                    # time.sleep(10)
                pass
                if str(file['material_id']) in ['726', '740', '759', '773']:
                    titleId2 = titleId[0: len(titleId) - 3]
                    # Evidence of planned tourism activities in Australia行程
                    self.huilianTools.click((By.ID, titleId2 + 'b1a0'), 2)
                    # time.sleep(1)
                    titleId1 = titleId2 + 'b1a0b2a0b'
                    self.huilianTools.select_by_value(
                        (By.NAME, titleId1), 'DT086')
                    # time.sleep(5)
                    titleId1 = titleId2 + 'b1a0b2c0b'
                    self.huilianTools.click((By.NAME, titleId1), 2)
                    # time.sleep(2)
                    self.kb.type_string(file['local_path'])
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(15)
                    titleId2 = titleId2 + 'b1a0b2f0'
                    self.huilianTools.click((By.NAME, titleId2), 2)
                    # time.sleep(10)
                pass
                if str(file['material_id']) in ['717', '733', '746', '766']:
                    titleId2 = titleId[0: len(titleId) - 3]
                    if financialType == '1':
                        # Evidence of the financial status and funding for visit资金证明
                        self.huilianTools.click((By.ID, titleId2 + 'b1a1'), 2)
                        # time.sleep(1)
                        financialType == '2'
                        familyDoc = '1'
                        idCardDoc = '1'
                        invitationDoc = '1'
                        passportDoc = '1'
                    pass
                    titleId1 = titleId2 + 'b1a1b2a0b'
                    # 上传银行流水
                    self.huilianTools.select_by_value(
                        (By.NAME, titleId1), 'DT010')
                    # time.sleep(5)
                    titleId1 = titleId2 + 'b1a1b2c0b'
                    self.huilianTools.click((By.NAME, titleId1), 2)
                    # time.sleep(2)
                    self.kb.type_string(file['local_path'])
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    titleId3 = titleId2 + 'b1a1b2f0'
                    self.huilianTools.click((By.NAME, titleId3), 2)
                    # time.sleep(10)
                pass
                if str(file['material_id']) in ['723', '737', '770']:
                    titleId2 = titleId[0: len(titleId) - 3]
                    if financialType == '1':
                        # Evidence of the financial status and funding for visit资金证明
                        self.huilianTools.click((By.ID, titleId2 + 'b1a1'), 2)
                        # time.sleep(1)
                        financialType == '2'
                        familyDoc = '1'
                        idCardDoc = '1'
                        invitationDoc = '1'
                        passportDoc = '1'
                    pass
                    titleId1 = titleId2 + 'b1a1b2a0b'
                    # 房产证
                    self.huilianTools.select_by_value(
                        (By.NAME, titleId1), 'DT160')
                    # time.sleep(5)
                    titleId1 = titleId2 + 'b1a1b2c0b'
                    self.huilianTools.click((By.NAME, titleId1), 2)
                    # time.sleep(2)
                    self.kb.type_string(file['local_path'])
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    titleId3 = titleId2 + 'b1a1b2f0'
                    self.huilianTools.click((By.NAME, titleId3), 2)
                    # time.sleep(10)
                pass
                if str(file['material_id']) in ['725', '739', '758', '772']:
                    titleId2 = titleId[0: len(titleId) - 3]
                    if invitationDoc == '1':
                        # Family register and composition form (if applicable)户口
                        self.huilianTools.click((By.ID, titleId2 + 'b1a2'), 2)
                        invitationDoc = '2'
                        familyDoc = '1'
                        idCardDoc = '1'
                        financialType = '1'
                        passportDoc = '1'
                    pass
                    # Evidence of planned tourism activities in Australia行程
                    # time.sleep(1)
                    titleId1 = titleId2 + 'b1a2b2a0b'
                    self.huilianTools.select_by_value(
                        (By.NAME, titleId1), 'DT127')
                    # time.sleep(5)

                    self.huilianTools.send_keys(
                        (By.NAME, titleId2 + 'b1a2b2b0b'), 'Invitation letter ')
                    titleId1 = titleId2 + 'b1a2b2c0b'
                    self.huilianTools.click((By.NAME, titleId1), 2)
                    # time.sleep(2)
                    self.log(file['local_path'])
                    self.kb.type_string(file['local_path'])
                    # time.sleep(4)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(15)
                    titleId2 = titleId2 + 'b1a2b2f0'
                    self.huilianTools.click((By.NAME, titleId2), 2)
                    # time.sleep(10)
                pass
                if str(file['material_id']) in ['724', '738', '757', '771']:
                    titleId2 = titleId[0: len(titleId) - 3]
                    if invitationDoc == '1':
                        # Family register and composition form (if applicable)户口
                        self.huilianTools.click((By.ID, titleId2 + 'b1a2'), 2)
                        invitationDoc = '2'
                        familyDoc = '1'
                        idCardDoc = '1'
                        financialType = '1'
                        passportDoc = '1'
                    pass
                    # Evidence of planned tourism activities in Australia行程
                    # time.sleep(1)
                    titleId1 = titleId2 + 'b1a2b2a0b'
                    self.huilianTools.select_by_value(
                        (By.NAME, titleId1), 'DT127')
                    # time.sleep(5)

                    self.huilianTools.send_keys(
                        (By.NAME, titleId2 + 'b1a2b2b0b'), 'Invitation letter ')
                    titleId1 = titleId2 + 'b1a2b2c0b'
                    self.huilianTools.click((By.NAME, titleId1), 2)
                    # time.sleep(2)
                    self.log(file['local_path'])
                    self.kb.type_string(file['local_path'])
                    # time.sleep(4)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(2)
                    self.kb.tap_key(self.kb.enter_key)
                    # time.sleep(15)
                    titleId2 = titleId2 + 'b1a2b2f0'
                    self.huilianTools.click((By.NAME, titleId2), 2)
                    # time.sleep(10)
                pass
            pass
            # 去支付页面
            nameTmp = 'index_' + str(random.randint(0, 99)) + '.png'
            self.log('name: %s' % nameTmp)
            self.driver.save_screenshot(nameTmp)
            text = self.driver.page_source
            self.log(text)
            index = text.find('Go to the next page')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            nextId = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, nextId), 2)
            # time.sleep(1)
            self.pagePay()
        except BaseException as e:
            self.except_log(e)

    # 上传文件页面
    def pagePay(self):
        try:
            # db.save("app", {"application_status": '3'}, "id=%s", [self.app_id])
            text = self.driver.page_source
            index = text.find('Submit Now')
            text = text[0:index]
            index = text.rfind('<button')
            text = text[index:len(text)]
            buttonName = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, buttonName), 2)
            # time.sleep(1)
            self.huilianTools.click((By.XPATH, '//input[@name="paymentMethod" and @value="CC"]'), 2)
            # time.sleep(1)
            self.huilianTools.send_keys((By.NAME, 'cardnumber'), '4561234564616545481')
            self.huilianTools.select_by_value((By.NAME, 'expirymonth'), '3')
            self.huilianTools.select_by_index((By.NAME, 'expiryyear'), 2)
            self.huilianTools.send_keys((By.NAME, 'cardname'), 'zhanghaoyu')
            self.huilianTools.send_keys((By.NAME, 'securityCode'), '0124')
            self.huilianTools.click((By.ID, 'submitButton'), 2)
            # time.sleep(1)
            nameTmp = 'index_' + str(random.randint(0, 99)) + '.png'
            self.log('name: %s' % nameTmp)
            self.driver.save_screenshot(nameTmp)
            self.huilianTools.click((By.NAME, 'yesButton'), 2)
            nameTmp = 'index_' + str(random.randint(0, 99)) + '.png'
            self.log('name: %s' % nameTmp)
            self.driver.save_screenshot(nameTmp)
        except BaseException as e:
            self.except_log(e)

    def testPay(self):
        try:
            # get方法会一直等到页面加载，然后才会继续程序，通常测试会在这里选择# time.sleep(2)
            self.driver.get("https://online.immi.gov.au/lusc/login")
            # 获取页面名为wraper的id标签的文本内容
            self.driver.find_element_by_name(
                'username').send_keys('1103776128@qq.com')
            self.driver.find_element_by_name('password').send_keys('Zhy123456')
            self.driver.find_element_by_name('login').click()
            # time.sleep(10)
            self.driver.find_element_by_name('continue').click()
            # time.sleep(10)
            app_no = 'EGOJY3JO3F'
            self.driver.find_element_by_name(
                'i_instantSearchFld').send_keys(app_no)
            self.driver.find_element_by_name(
                'btn_perform_instant_srch').click()
            # time.sleep(10)
            nameTmp = 'index_' + str(random.randint(0, 99)) + '.png'
            self.log('name: %s' % nameTmp)
            self.driver.save_screenshot(nameTmp)
            self.driver.find_element_by_id('actionPanel_0_9').click()
            # time.sleep(10)
            self.driver.find_element_by_name('confirmBtn').click()
            # time.sleep(10)
            self.driver.find_element_by_xpath(
                '//input[@name="paymentMethod" and @value="CC"]').click()  # 这个应用程序是作为一组应用程序的一部分提交的吗？默认选否
            # time.sleep(5)
            self.driver.find_element_by_name('cardnumber').send_keys('')
            select = Select(
                self.driver.find_element_by_name('expirymonth'))  # 有效期
            select.select_by_value('1')  # 0123
            select = Select(
                self.driver.find_element_by_name('expiryyear'))  # 有效期
            select.select_visibility_by_text('23')
            self.driver.find_element_by_name('cardname').send_keys('')
            self.driver.find_element_by_name('securityCode').send_keys('')
            # time.sleep(5)
            self.driver.find_element_by_id('submitButton').click()

            # time.sleep(3)
            nameTmp = 'index_' + str(random.randint(0, 99)) + '.png'
            self.log('name: %s' % nameTmp)
            self.driver.save_screenshot(nameTmp)
            self.driver.find_element_by_name('yesButton').click()
            nameTmp = 'index_' + str(random.randint(0, 99)) + '.png'
            self.log('name: %s' % nameTmp)
            self.driver.save_screenshot(nameTmp)
        except BaseException as e:
            self.except_log(e)

    # 循环下载文件
    def material_down(self):
        self.log('待上传资料开始下载...')
        self.fileList = []

        for index in range(len(self.material_list)):
            downfile = self.material_list[index]
            path = downfile['path']
            filepath, shotname, extension = self.Tools.jwkj_get_filePath_fileName_fileExt(path)
            fileName = shotname + extension
            downfile['local_path'] = self.Tools.repr(self.local_path + fileName)
            # self.log(downfile['local_path'])
            self.fileList.append(downfile)
            self.FileTools.down_file(path, self.local_path, self.app_id, (index + 1), len(self.material_list))
        pass
        for index in range(len(self.fileList)):
            file = self.fileList[index]
            self.log('服务器路径：%s 本地路径：%s' % (file['path'], file['local_path']))
        self.log('待上传资料下载完毕----')
    pass

    def testAoRegister(self):
        # get方法会一直等到页面加载，然后才会继续程序，通常测试会在这里选择# time.sleep(2)
        try:
            self.driver.get("https://online.immi.gov.au/lusc/register")
            nameTmp = '_' + str(random.randint(0, 99)) + '.png'
            self.log('name: %s' % nameTmp)
            self.driver.save_screenshot(nameTmp)
            # time.sleep(5)
            # self.log(self.driver.page_source)
            # 获取页面名为wraper的id标签的文本内容
            self.driver.find_element_by_name('_2b0e1a0a0g1a1b1b0').click()
            self.driver.find_element_by_name(
                '_2b0e1a0a0g1a1b1b0').send_keys('Zhang')  # 名
            self.driver.find_element_by_name(
                '_2b0e1a0a0g1a1b2b0').send_keys('HaoYu')  # 名
            self.driver.find_element_by_name(
                '_2b0e1a0a0g1a1b3b').send_keys('85001024')  # 电话
            self.driver.find_element_by_name(
                '_2b0e1a0a0g1a1b4b').send_keys('18113181706')  # 手机
            self.driver.find_element_by_name(
                '_2b0e1a0a0g1a1d0b0').send_keys('zhy8945@163.com')  # 邮箱
            self.driver.find_element_by_name(
                '_2b0e1a0a0g1a1d1b').send_keys('zhy8945@163.com')  # 确认邮箱
            self.driver.find_element_by_name('_2b0e1b0b0b').click()  # 下一步
            # time.sleep(5)
            nameTmp = '_' + str(random.randint(0, 99)) + '.png'
            self.log('name: %s' % nameTmp)
            self.driver.save_screenshot(nameTmp)
            self.driver.find_element_by_name(
                '_2b0e1a0b0b4a1').send_keys('Zhy123456')  # 密码
            self.driver.find_element_by_name(
                '_2b0e1a0b0b4c1').send_keys('Zhy123456')  # 确认密码
            # 找到 name 的选项卡
            select = Select(self.driver.find_element_by_name(
                '_2b0e1a0b0c2a-r0-_0a0b0'))  # 安全问题1
            select.select_by_index(1)
            self.driver.find_element_by_name(
                '_2b0e1a0b0c2a-r0-_0a2b').send_keys('anquandaan1')  # 安全答案1
            select = Select(self.driver.find_element_by_name(
                '_2b0e1a0b0c2a-r1-_0a0b0'))  # 安全问题2
            select.select_by_index(2)
            self.driver.find_element_by_name(
                '_2b0e1a0b0c2a-r1-_0a2b').send_keys('anquandaan2')  # 安全答案2
            select = Select(self.driver.find_element_by_name(
                '_2b0e1a0b0c2a-r2-_0a0b0'))  # 安全问题3
            select.select_by_index(3)
            self.driver.find_element_by_name(
                '_2b0e1a0b0c2a-r2-_0a2b').send_keys('anquandaan3')  # 安全答案3
            self.driver.find_element_by_name(
                '_2b0e1a0b0e1b1b').click()  # 接受创建条款
            text = self.driver.page_source
            # 机器人检测按钮为动态ID 需要截取字符串获取
            index = text.find('I am not a robot')
            text = text[0:index]
            index = text.rfind('<div')
            text = text[0:index]
            index = text.rfind('<div')
            text = text[index:len(text)]
            id = pub.get_reg_value(r'(?<=div id=").*?(?=")', text)
            self.driver.find_element_by_id(id).click()  # 机器人检测
            self.driver.find_element_by_name('_2b0e1b0b0a').click()  # 提交
            # 打印数据内容
            nameTmp = '_' + str(random.randint(0, 99)) + '.png'
            self.log('name: %s' % nameTmp)
            self.driver.save_screenshot(nameTmp)
            self.driver.quit()
        except Exception as e:
            self.except_log(e)

    def testDoc(self):
        try:
            file = self.fileList[0]
            self.log(file['local_path'])
            self.driver.get("file:///D:/testFile.html")
            self.driver.find_element_by_id("file").click()
            # time.sleep(3)
            self.kb.type_string(file['local_path'])
            # time.sleep(2)
            self.kb.tap_key(self.kb.enter_key)
            # time.sleep(2)
            self.kb.tap_key(self.kb.enter_key)
        except Exception as e:
            self.except_log(e)
    pass

    def deleteData(self):
        text = self.driver.page_source
        index = text.find('Delete')
        if index > 0:
            text = text[0:index]
            index = text.rfind('<button name')
            text = text[index:len(text)]
            btnName = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, btnName), 2)
            # time.sleep(5)
            self.kb.tap_key(self.kb.enter_key)
            # time.sleep(5)
            self.deleteData()
        pass
    pass

    def deleteDoc(self):
        text = self.driver.page_source
        index = text.find('Are you sure you want to delete the file')
        if index > 0:
            text = text[0:index]
            index = text.rfind('<button name')
            text = text[index:len(text)]
            btnName = pub.get_reg_value(r'(?<=button name=").*?(?=")', text)
            self.huilianTools.click((By.NAME, btnName), 2)
            # time.sleep(5)
            self.kb.tap_key(self.kb.enter_key)
            # time.sleep(5)
            self.deleteDoc()
        pass
    pass

    def GetBankCardInfo(self):
        try:
            req = self.get('http://192.168.0.249:8081/public/getBankCardInfo')
            '''登陆页面内容'''
            text = req.content
            self.log(text)
            accountData = json.loads(text)
            data = accountData['account']
            if(len(data) % 3 == 1):
                data += "=="
            elif(len(data) % 3 == 2):
                data += "="
            data = bytes(data, encoding='utf8')
            data = base64.b64decode(data)
            bs = AES.block_size
            if len(data) <= bs:
                return data
            iv = data[:bs]
            unpad = lambda s : s[0:-ord(s[-1])]
            cryptor = AES.new(accountData['salt'], AES.MODE_CBC, iv)
            data = unpad(cryptor.decrypt(data[bs:]))
            self.log(data)
        except Exception as e:
            self.except_log(e)
    pass

    def except_log(self, e):
        self.log(debug='type(Exception):\t%s' % str(type(e)))
        self.log(debug='traceback.format_exc():\n%s\n%s' % (str(traceback.format_exc()), "-" * 150))
        self.driver.quit()

    def get_labels(self, titleId, ids, attribute):
        elements = self.huilianTools.find_elements((By.CSS_SELECTOR, f"#{titleId}>.wc-content>div"), 2)
        element = elements[ids].get_attribute("id")
        labels = self.huilianTools.find_elements((By.CSS_SELECTOR, f"#{element} {attribute}"))
        return labels


if __name__ == "__main__":
    logger = settings.get_log("main")
    # cls = implement_class(348, '', '')
    # cls.testAoLogin()
    try:
        cls = implement_class(348, '', '')
        cls.testAoLogin()
        # cls.testPay()
        # cls.testAoLogin()
        # cls.testAoRegister()
        # cls.testPrint()
        # cls.testXinxilan()
        # cls.testDoc()
        # cls.testUpload()
        # cls.material_down()
        # cls.testDoc()
        # cls.GetBankCardInfo()
    except Exception as e:
        logger.debug('type(Exception):\t%s' % str(type(e)))
        logger.debug('traceback.format_exc():\n%s\n%s' % (str(traceback.format_exc()), "-" * 150))
        # logger.debug('str(e):        \t%s' % str(e))
        # logger.debug('repr(e):       \t%s' % repr(e))
        # logger.debug('e.message:     \t%s' % e.message if hasattr(e, "message") else str(e))
        # logger.debug('traceback.print_exc(): %s' % traceback.print_exc())
    # finally:
    #     self.driver.quit()
